package jdbc1;

import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;

public class TestConn {
    public static void main(String[] args) throws Exception {
        Properties properties = new Properties();
        //i/o
        FileInputStream fileInputStream = new FileInputStream("src\\jdbc.properties");
        properties.load(fileInputStream);
        String user = properties.getProperty("user");
        String password = properties.getProperty("password");
        String url = properties.getProperty("url");
        String driver = properties.getProperty("driver");

        System.out.println("user = " + user);
        System.out.println("password = " + password);
        System.out.println("url = " + url);
        System.out.println("driver = " + driver);
        Class.forName(driver);
        Connection connection = DriverManager.getConnection(url, user, password);
        System.out.println("connection = " + connection);
        Statement statement = connection.createStatement();
        String s = "select * from current_use";
        ResultSet resultSet = statement.executeQuery(s);
        boolean next = resultSet.next();
        int anInt = resultSet.getInt("id");
        System.out.println("anInt = " + anInt);
    }
}
